package com.android.bonn.fast

import android.content.Intent
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.recyclerview.widget.LinearLayoutManager
import com.android.bonn.fast.adapter.SimpleCellDelegateAdapter
import com.android.bonn.fast.adapter.ext.buildCells
import com.android.bonn.fast.adapter.ext.create
import com.android.bonn.fast.databinding.ActivityMainBinding
import com.android.bonn.fast.statusbar.AndroidStatusBarUtils

class MainActivity : AppCompatActivity() {

  private lateinit var mBinding: ActivityMainBinding
  private lateinit var adapter: SimpleCellDelegateAdapter

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    mBinding = ActivityMainBinding.inflate(layoutInflater)
    setContentView(mBinding.root)

    AndroidStatusBarUtils.translucent(this)

    mBinding.testListView.layoutManager = LinearLayoutManager(this)
    adapter = mBinding.testListView
      .buildCells()
      .create(R.layout.item_view_layout, { ExampleCellView(it) }, { _, _ -> true })
      .build()
    mBinding.testListView.adapter = adapter
    adapter.submitList(getTestData())
  }


  private fun getTestData() = mutableListOf(
    ExampleModel("Any object list") {
      startActivity(
        Intent(
          this,
          AnyListActivity::class.java
        )
      )
    },
    ExampleModel("Any adapter") {
      startActivity(
        Intent(
          this,
          AnyAdapterListActivity::class.java
        )
      )
    },
  )
}